from datetime import date
from django.shortcuts import render_to_response
from django.template import RequestContext
from lotto.const import GAME


def search (request):
    lotto = [];
    query = request.GET.get ('search', '');
    if not query:
        query = date.today ().strftime ('%Y-%m-%d');
    for l in GAME:
        try:
            lotto.append (GAME[l].objects.get (date = query));
        except:
            pass;
    return render_to_response ('search/search.html',
							   {'lotto':lotto, 'query':query},
    						   context_instance = RequestContext (request));


